home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
JCSM Shareware Collection 1993 November
/
JCSM Shareware Collection - 1993-11.iso
/
cl760
/
garfforj.lzh
/
GRAPH.FOR
< prev
next >
Wrap
Text File
|
1991-01-17
|
9KB
|
206 lines
PROGRAM GRAPH
*---------------------------------------------------------------------
* Fortran source GRAPH.for v3.0 Copyright (C) D.I.Hoyer, 1991
*---------------------------------------------------------------------
COMMON /GRF/XMINA,XMAXA,YMINA,YMAXA,XMIN,YMIN,XMAX,YMAX,MAXX,
$ MAXY,MMAXX,MMAXY,LOHI,IVH,LOGX,LOGY,DPIV,DPIH
INTEGER*2 IGRAPH
CHARACTER*80 GLABEL, XLABEL, YLABEL, LEGEND, STRNG
DIMENSION IGRAPH(1040,110), X(200), Y(200), P(20)
*----------------------------------------------------------------------
* Graph plotting on dot matrix printers.
*
* This is a sample main program for plotting a graph from a data file,
* which must be set up as described in the manual.
*
* The program set for IBM, Epson LX-800, and Star type dot matrix printers.
* If you have a printer which uses different graphics commands, or if
* the graph doesn't appear to print properly, check your printer manual
* and change the appropriate parameters in subroutine PRTGRF.
*
* Maximum graph size (nominal, for Hi-res plotting) = 20 x 25 cm.
*
* If your compiler cannot handle large arrays
* --------------------------------------------
* (bigger than 64k say) you will have to re-dimension the
* DIMENSION IGRAPH(1040,110) statement at the top of this file:
* DIMENSION IGRAPH(a,b) : a = max no. of dot columns across page
* b = (max no of dot rows)/14 + 1
* Memory required = 2*a*b bytes.
* Maximum graph width = a/(horizontal dots per inch)
* Maximum graph height = 14*b/(vertical dots per inch)
* Try out some values to see which compile correctly, giving you a page
* width and height which is acceptable. Obviously in high resolution
* the maximum graph size will be smaller. You will have to make sure
* that you don't specify axis lengths too long for the IGRAPH array size:
* XL, YL, BWLEFT, BWRGHT, BWTOP, BWBOTT. You may have to modify the
* appropriate lines in the graph.00? files (line 4 in each file).
*
* GLABEL, XLABEL & YLABEL : Graph heading, and X & Y axis labels.
* XL = Length of x-axis, cm.
* YL = Length of y-axis, cm.
* BWLEFT = Border width to left of axes, cm.
* BWRGHT = Border width to right of axes, cm.
* BWTOP = Border width above axes, cm.
* BWBOTT = Border width below axes, cm.
* IORIYV = Orientation of y-axis values.
* (0=numbers parallel to y-axis, 1=perpendicular to y-axis)
* MAXX = Number of dots across x-axis. (calculated by PREP)
* MAXY = Number of dots along y-axis. (calculated by PREP)
* XMIN, XMAX, YMIN, YMAX = Min & max x,y values to define edges of
* plotting area.
* XMINA, XMAX, YMINA, YMAXA = Total plotting area, including space above,
* below and left of the graph for labels. These
* are calculated by PREP
* NDIVX, NDIVY = No of divisions along axes (0 for log. scales)
* NSDIVX, NSDIVY = No of secondary divisions along axes (between other
* divisions). Use 1 or 9 for log. scales.
* NDPX, NDPY = No of decimal places to be printed after dec. point, for
* axis values. Ignored for log. scales.
* IVH = 1 for vertical (portrait) printout, 2 for horizontal (landscape).
* IGRPRT= 1 to print the axes,
* 0 to suppress printing of axes.
* LOHI = 1 for Low-res (quick) plot, 2 for Hi-Res.
* IOFF = Offset. This number of blank spaces will be printed from the left
* margin ahead of the graph.
* IGRDx1,x2,y1,y2 = 1 to n for grid lines of line type LTYP (major/minor divs),
* 0 for no grid lines.
* ISZTTL= The text size for printing the graph title
* TTLPOS= To adjust the distance between axis and centre of graph title.
* (>0 = Above top axis, <0 = below bottom axis
* magnitude: 1=default, <1=closer to axis, >1=further from axis)
* XLBPOS= To adjust the distance between x-axis and x-axis label.
* 1=default, <1=closer to axis, >1=further from axis.
* YLBPOS= As for XLBPOS, but for y-axis. eg. If IORIYV=1 and the y-axis
* values are several characters long, set YLBPOS>1 to shift the
* label further away from the axis.
* JUSTTL= Justification of graph title. (-1=left, 0=centre, 1=right)
* LGDPOS= Position of legend block. 1 = top left, to 4 = top right.
* 5 = bott. " , to 8 = bott. " .
* LGDSIZ= Size of text for legend table (for drawing the legend box)
* LGDPOS= Position of the legend box.
* (1..4 = top left to top right, 5..8 = bottom left to bottom rt)
* LGDLNS= Number of lines of text to be allocated for legend box
* (set to 0 for no legend box)
* LGDCHS= Max number of characters in a legend text (for the legend box)
* LGDTYP= Line type for surrounding the legend box (0=none, 1=solid etc)
* NPTS = No of data points for current data set, or if <=0 then..
* 0 to plot a function curve,
* -1 for plotting a text string,
* -2 to clear a rectangular area of the graph, with optional border.
* LTYP = Line type for joining points.
* 0 = no line,
* 1 to 5 straight lines,
* -5 to -1 for cubic spline fit (smooth curve).
* MARK = Symbol to be plotted at each point
* (1 = dot, 2..8 = symbol, 32..126 = ASCII character)
* MSIZE = Size of MARK (1..n) Try 2 or 3 for a start.
* LEGEND= Text to describe each data set.
* Blank to suppress.
* IFN = Function number (pre-compiled in FUNCT) to plot if NPTS=0.
* NPARMS= Number of parameters to be passed to function IFN (max 100).
* P(J),J=1,NPARMS = The parameters to be passed to function IFN.
* ITXSIZ= Size of text to be plotted (1 to n). 2 = "normal".
* STRNG = A string of text to be printed on the graph
*
* MMAXX,MMAXY are for passing the dimension of IGRAPH through subs.
* (calculated by PREP)
* MMAXX is the number of columns of dots across the page,
* MMAXY is the (number of rows of dots)/14
*
READ(5,101) GLABEL
READ(5,101) XLABEL
READ(5,101) YLABEL
READ(5,505) XL, YL, BWLEFT, BWRGHT, BWTOP, BWBOTT
READ(5,505) XMIN, XMAX, YMIN, YMAX
READ(5,202) NDIVX, NSDIVX, IGRDX1, IGRDX2, NDPX
READ(5,202) NDIVY, NSDIVY, IGRDY1, IGRDY2, NDPY
READ(5,202) ISZVAL, ISZXYL, IORIYV, ISZTTL, JUSTTL
READ(5,505) VALPOS, XLBPOS, YLBPOS, TTLPOS
READ(5,202) IGRPRT, IVH, LOHI, IOFF
READ(5,202) LGDPOS, LGDLNS, LGDCHS, LGDSIZ, LGDTYP
*
101 FORMAT(A80)
202 FORMAT(8I10)
505 FORMAT(8F10.0)
*
* Do some preparations/calcs before plotting axes or data.
* Subroutine PREP must be called before any plotting is done.
*
LOGX = NDIVX
LOGY = NDIVY
DPIH = 60.
DPIV = 72.
CALL PREP(XMIN,YMIN,XMAX,YMAX,LOGX,LOGY,LOHI,IVH,XL,YL,BWLEFT,
$ BWRGHT,BWTOP,BWBOTT,DPIV,DPIH)
*
* Clear the graph (this is only necessary if you want your program
* to print more than one graph, as the first graph is clear when you start).
* Remove the comment asterisk in column 1 to activate the next line if you
* need to clear the graph:
*
* CALL CLRGRF(MMAXX,MMAXY,IGRAPH)
*
* Draw the axes
*
IF(IGRPRT.EQ.1) CALL AXES(NDIVX,IGRDX1,NSDIVX,IGRDX2,NDPX,XLABEL,
$ NDIVY,IGRDY1,NSDIVY,IGRDY2,NDPY,YLABEL,IORIYV,GLABEL,ISZVAL,
$ VALPOS,ISZXYL,XLBPOS,YLBPOS,ISZTTL,TTLPOS,JUSTTL,LGDSIZ,LGDPOS,
$ LGDLNS,LGDCHS,LGDTYP,IGRAPH)
*
* Read and plot the sets of data. Each set of data can be one of...
* a) Clearing a rectangular area of the graph, with optional border;
* b) Write text at (x,y), with any size, orientation and justification;
* c) Plot one of the continuous functions from subroutine GRAPHFNS
* d) Plot a set of points, with optional straight lines or smooth curve
* through the points.
*
ILEGND = 0
1000 READ(5,707) NPTS, LTYP, MARK, MSIZE, INOUT, LEGEND
707 FORMAT(5I5,A)
* NPTS=-99 indicates end of data. Plot the graph and terminate the program.
IF(NPTS.EQ.-99) GOTO 2000
* If NPTS=-2 then clear a rectangular graph area between coordinates
* (x1,y1) to (x2,y2)
IF(NPTS.EQ.-2) THEN
READ(5,505) X(1), Y(1), X(2), Y(2)
* If NPTS=-1 then plot text at coordinate value (xx,yy) .
ELSEIF(NPTS.EQ.-1) THEN
READ(5,808) IORI, ITXSIZ, JUSTIF, X(1), Y(1)
808 FORMAT(3I10,2F10.0)
READ(5,909) STRNG
909 FORMAT(A)
* If NPTS=0 then a function plot is required.
ELSEIF(NPTS.EQ.0) THEN
READ(5,404) IFN, NPARMS, X(1), X(2)
404 FORMAT(2I10,2F10.0)
READ(5,505) (P(J),J=1,NPARMS)
* Otherwise a set of points is to be plotted
ELSE
READ(5,303) (X(J),Y(J),J=1,NPTS)
303 FORMAT(2F10.0)
ENDIF
*-------Plot the data set (text, function or points)
CALL PLOTD(NPTS,LTYP,MARK,MSIZE,LEGEND,IORI,ITXSIZ,JUSTIF,
$ INOUT,IGRAPH,STRNG,IFN,P,X,Y,ILEGND,LGDPOS,LGDSIZ)
*
* Print out the graph
*
GOTO 1000
2000 CALL PRTGRF(IOFF,MMAXX,MMAXY,LOHI,IGRAPH)
STOP
END
*---------------------------------------------------------------------------
* Include the subroutine libraries...
INCLUDE "GRAPHFNS.for"
INCLUDE "GRAPHLIB.for"
*---------------------------------------------------------------------------